home *** CD-ROM | disk | FTP | other *** search
- // A cheep file prompt for selecting PGN files.
- //
- // History
- // 1995/09/05 By R. Mark Fleming <markf@post.queensu.ca>\
- // Provide the basic file select to replace unix command line prompt.
- //
- #include <stdlib.h>
- #include <stdio.h>
-
- #include <Files.h>
- #include <LowMem.h>
- #include <StandardFile.h>
- #include <Memory.h>
-
- int _Main( int argc, char *argv[]);
- int main( int argc, char *argv[])
-
- { StandardFileReply reply;
- SFTypeList typeList;
- OSErr err = noErr;
- FInfo ioFlFndrInfo;
- long type, creator;
- short savedVol;
- char *Myargv[2];
- Str255 appName;
-
- BlockMoveData((Ptr)LMGetCurApName(), (Ptr)appName, sizeof(Str31)); // Get the current application name
- p2cstr(appName);
- Myargv[0] = (char *) &appName[0]; // Arg[0] = application name
-
- fprintf(stderr, "%s\nFreeware, convert to Macintosh by Mark Fleming\n", appName);
-
- StandardGetFile(nil, -1, typeList, &reply);
- while (reply.sfGood && err == noErr) {
-
- err = FSpGetFInfo(&reply.sfFile, &ioFlFndrInfo);
-
- creator = ioFlFndrInfo.fdCreator; // If need check creator or type...
- type = ioFlFndrInfo.fdType;
-
- err = GetVol(0, &savedVol);
- if (err == noErr)
- {
- err = HSetVol(0, reply.sfFile.vRefNum, reply.sfFile.parID);
- if (err == noErr)
- {
- p2cstr(reply.sfFile.name);
- Myargv[1] = (char *)reply.sfFile.name;
-
- fprintf(stderr, "Processing file: %s\n", Myargv[1]);
-
- _Main(2, Myargv);
-
- c2pstr((char*)reply.sfFile.name);
- }
- SetVol(0, savedVol);
- }
-
- if (err != noErr) SysBeep(0); /* End if Err */
-
- StandardGetFile(nil, -1, typeList, &reply);
- } // End while()
-
- fprintf(stderr, "\nSelect Quit from File menu to exit %s.\n", Myargv[0]);
-
- return err;
- } /* End of () */
-